package com.armed.client.interfaz.comparativas;

import com.armed.ejb.transference.TipoProducto;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

public class ComparativeComboBoxRenderer extends JLabel implements ListCellRenderer
{
    /**
     * 
     */
    public ComparativeComboBoxRenderer()
    {
        setOpaque(true);
        setHorizontalAlignment(LEFT);
        setVerticalAlignment(CENTER);
    }
    
    public Component getListCellRendererComponent(JList list,Object value,int index,boolean isSelected,boolean cellHasFocus) 
    {
        if (value instanceof TipoProducto)
        {
            TipoProducto prod = (TipoProducto)value;
            setText(prod.getLinea());
        }
        if (value instanceof String)
            setText((String)value);

        if (isSelected) 
        {
            setBackground(list.getSelectionBackground());
            setForeground(list.getSelectionForeground());
        } 
        else 
        {
            setBackground(list.getBackground());
            setForeground(list.getForeground());
        }

        return this;
    }
}